<template>
  <div class="like">
    <div class="title">
      猜你喜欢
    </div>
    <div class="goods-list">
      <div
        v-for="item in likeList"
        :key="item.id"
        class="goods-item"
        @click="todetail(item)"
      >
        <div class="goods-img">
          <img
            :src="item.defaultAlbum"
            alt=""
          >
        </div>
        <div class="goods-info">
          <div class="name">
            {{ item.cProductShowName }}{{ item.cModelDescription }}
          </div>
          <div class="price">
            ￥{{ item.fSalePrice }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: ["goods_id_exclude", "categoryid"],
  data() {
    return {
      likeList: [],
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    //获取列表
    getData() {
      let params = {
        queryCondition: {
          order: [
            {
              fieldname: "iOrder",
              direction: "asc",
            },
          ],
          pagesize: 20,
          pageindex: 1,
          where: [
            {
              fieldname: "goods_id_exclude",
              valuefrom: "",
            },
            {
              fieldname: "categoryid",
              valuefrom: "",
            },
            {
              fieldname: "type",
              valuefrom: 1,
            },
          ],
        },
      };
      this.$api.home.getRecommendCartList(params).then((res) => {
        if (res.code == 200) {
          // console.log(res.data);
          this.likeList = res.data.data;
        }
      });
    },
    todetail(item) {
      this.$router.push({
        path: "/fruit/detail",
        query: {
          id: item.pid,
          iShopId: item.iShopId
        },
      });
    },
  },
};
</script>

<style scoped lang="scss">
.like {
  padding: 0 16.19rem;
  margin-top: 2.19rem;
  display: flex;
  flex-direction: column;

  .title {
    font-size: 1.13rem;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #333333;
  }

  .goods-list {
    margin-top: 1.88rem;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;

    .goods-item {
      width: 24%;
      height: 20.88rem;
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-right: 1%;
      margin-bottom: 2.38rem;
      cursor: pointer;

      &:nth-child(4n) {
        margin-right: 0;
      }

      .goods-img {
        width: 100%;
        height: 18rem;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;

        img {
          width: 15rem;
          height: 15rem;
          object-fit: contain;
        }
      }

      .goods-info {
        width: 17.1rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 0.63rem;
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap
        .name {
          font-size: 0.88rem;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #040000;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 100%;
        }

        .price {
          font-size: 1.09rem;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #f0406f;
          margin-top: 0.38rem;
        }
      }
    }
  }
}
</style>
